<template>
	<view class="rich-page">
		<bsNavBar :title='name'></bsNavBar>
		<view class="title">
			{{name}}
		</view>
		<view class="time">
			{{typeList[Number(details.category)]}} <text style="margin: 0 10rpx;">|</text> {{details.createTime}}
		</view>
		<u-parse :html="content"></u-parse>
		<view class="mt-40 mb-40" v-if="showTips">
			<u-alert-tips :show-icon='true' type="warning" :description="description"></u-alert-tips>
		</view>
		<image @click="handColl" v-if="!favoritesId" class="shoucang" :src="imgUrl+'shoucang-n.png'" mode=""></image>
		<image v-else class="shoucang" :src="imgUrl+'shoucang-y.png'" mode=""></image>
	</view>
</template>

<script>
	export default {
		// props: {
		// 	content: {
		// 		type: String,
		// 		default: ''
		// 	}
		// },
		async onLoad(e) {
			if (e.newsId) {
				this.newsId = e.newsId
				await this.init()
			}
		},
		data() {
			return {
				typeList: ['新闻资讯', '协会动态', '热点话题', '攻略指南', '政策研究', '行业公示', '下载中心', '年度人物大赛报道', '年度人物往期回顾', '年度人物公益巡演', '金鹰奖大赛报道',
					'金鹰奖往期回顾',
					'科技奖获奖公示', '科技奖相关资讯'
				],
				details: {},
				newsId: '',
				imgUrl: this.configImgUrl,
				showTips: false,
				description: '注：以上奖项如需申报，请使用电脑访问官方网站提交申请  官网地址：www.cbda1984.com ',
				content: '',
				name: '详情',
				favoritesId: null
			};
		},
		methods: {
			async init() {
				let res = await this.$u.api.selectNewsFIRST({
					newsId: this.newsId
				})
				console.log(res, '新闻详情')
				this.name = res.title
				this.favoritesId = res.favoritesId
				this.content = res.content
				this.details = res
			},
			async handColl() {
				let res = await this.$u.api.addMyFavorites({
					newsId: this.newsId
				})
				await this.init()
				uni.showToast({
					title: '收藏成功'
				})
			}
		}
	}
</script>

<style lang="scss">
	.rich-page {
		padding: 30rpx;

		.title {
			font-size: 44rpx;
			color: #303030;
			margin-bottom: 30rpx;
		}

		.time {
			color: #9A9A9A;
			font-size: 28rpx;
			margin-bottom: 50rpx;
		}

		.shoucang {
			position: fixed;
			bottom: 35rpx;
			right: 35rpx;
			width: 140rpx;
			height: 140rpx;
		}
	}
</style>
